package com.cskaoyan.controller.wx;

import com.cskaoyan.bean.BasePageInfo;
import com.cskaoyan.bean.vo.BaseRespVo;
import com.cskaoyan.bean.MarketCollect;
import com.cskaoyan.bean.param.CommonData;
import com.cskaoyan.service.admin.MarketCollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author LC_RSH
 * @date 2022/6/28 20:04
 */
@RestController
@RequestMapping("wx/collect")
@Transactional
public class WXCollectController {
    @Autowired
    MarketCollectService marketCollectService;

    /**
     * 根据type查找收藏
     *
     * @return 收藏列表
     * @author LC_R-SH
     * @since 2022/06/28 20:13
     */
    @RequestMapping("list")
    public BaseRespVo list(Byte type, BasePageInfo info) {
        CommonData<MarketCollect> data = marketCollectService.queryByType(type, info);
        return BaseRespVo.ok(data);
    }

    /**
     * 根据collect是否已收藏进行添加或删除
     * @return 返回成功或失败信息
     * @author LC_R-SH
     * @since 2022/06/28 20:47
     */
    @RequestMapping("addordelete")
    public BaseRespVo addOrDelete(@RequestBody MarketCollect collect) {
        BaseRespVo baseRespVo = marketCollectService.addOrDelete(collect);
        return baseRespVo;
    }

}

/**
 * 收藏夹
 *
 * @author 86157
 * @since 2022/06/28 20:04
 */